package jt.classic.system.listener;

import jt.classic.system.ISystemException;

import org.limp.basework.AbstractSimpleBean;
import org.limp.basework.SimpleBean;
import org.limp.basework.SimpleBeanMachining;

import java.util.Map;


/**
 * 操作监听器
 *
 * @author mido
 *
 */
public class IListener extends AbstractSimpleBean implements SimpleBean {
    private String id;
    private String desc;
    private String name;

    /**
     * 获取数据加工器接口实例
     * @return SimpleBeanMachining
     * @throws ISystemException
     */
    public SimpleBeanMachining getSBM() throws ISystemException {
        SimpleBeanMachining obj = null;

        try {
            obj = (SimpleBeanMachining) Class.forName(this.name).newInstance();
        } catch (Exception ex) {
            throw new ISystemException("get listener['" + this.id +
                "'] sbm instance error.", ex);
        }

        return obj;
    }

    /**
     * 接口描述
     * @return String
     */
    public String desc() {
        return desc;
    }

    /**
     * 接口ID
     * @return
     */
    public String id() {
        return id;
    }

    /**
     * 监听器实现类名称
     * <p>接口org.limp.basework.SimpleBeanMachining实现类</p>
     * @return String
     */
    public String name() {
        return name;
    }

    public void reload(Map map) {
        if (map != null) {
            this.info = map;
        }

        this.id = (String) this.info.get("id");
        this.desc = (String) this.info.get("desc");
        this.name = (String) this.info.get("name");
    }
}
